//
//  MyselfViewController.m
//  Bettle
//
//  Created by jackli on 2017/1/10.
//  Copyright © 2017年 panhongliu. All rights reserved.
//
#import "MyselfTableViewCell.h"
#import "HeaderView.h"
#import "MyselfViewController.h"

@interface MyselfViewController ()
@property(nonatomic,strong)NSMutableArray *dicArray;
@property(nonatomic,strong)NSDictionary *hederViewDic;

@end

@implementation MyselfViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    [NetworkManger getCacheRequestWithUrlString:@"/beetle/inter/customer/getUserPhoto?uuid=13935143147" parameters:nil cacheTime:NO succeed:^(id data) {
        
        self.hederViewDic =data[@"values"];
      
        
        [self.tableview reloadData];
        
        
    } fail:^(NSError *error) {
        
    }];

    [self customTableView];
    self.tableview.frame=CGRectMake(0, 0, ScreenWidth, ScreenHeight-49);
    self.tableview.backgroundColor = UIColorFromRGB(0xf3f3f3);
    UINib *footerNib= [UINib nibWithNibName:@"MyselfTableViewCell" bundle:nil];
    [self.tableview registerNib:footerNib forCellReuseIdentifier:@"MyselfTableViewCell"];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        HeaderView *header = [HeaderView initHeaderView];
        header.dictionary= self.hederViewDic;
        header.frame=CGRectMake(0, 0, SCREEN_WIDTH,337);
        return header;
    }else{
        UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5)];
        view1.backgroundColor =UIColorFromRGB(0xf3f3f3);
        return view1;
    }
       ;
   }
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 1)];
    view1.backgroundColor = UIColorFromRGB(0xe5e5e5);
    if (section == 0) {
        return nil;
    }else{
        return view1;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{    
        return 1;
}
//每组的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  
    if (section==0) {
        return 0;
    }else if (section == 3){
        return 1;
    }else{
        return 2;
    }
    
}
//cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 //   MyselfTableViewCell *model=self.dataArray[indexPath.row];
    
    NSArray *imagearray = @[@"personalcenter_icon_01",@"personalcenter_icon_02",@"personalcenter_icon_03",@"personalcenter_icon_04",@"personalcenter_icon_05",@"personalcenter_icon_arrow"];
    NSArray *lableArray = @[@"时光记忆",@"我的礼物",@"我的动态",@"我的金库",@"我的订单"];
    
    MyselfTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyselfTableViewCell" forIndexPath:indexPath];
    if (indexPath.section ==1) {
        cell.titleImageView.image = [UIImage imageNamed:imagearray[indexPath.row]];
        cell.contextLable.text =lableArray[indexPath.row];
        cell.lastImageView.image = [UIImage imageNamed:imagearray[5]];
    }if (indexPath.section==2) {
        cell.titleImageView.image = [UIImage imageNamed:imagearray[indexPath.row+2]];
        cell.contextLable.text =lableArray[indexPath.row+2];
        cell.lastImageView.image = [UIImage imageNamed:imagearray[5]];
    }if (indexPath.section==3) {
        cell.titleImageView.image = [UIImage imageNamed:imagearray[indexPath.row+4]];
        cell.contextLable.text =lableArray[indexPath.row+4];
        cell.lastImageView.image = [UIImage imageNamed:imagearray[5]];
    }

    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    
    
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   // MyselfTableViewCell *model=self.dataArray[indexPath.row];
    
    //DetailsTableViewController *details = [[DetailsTableViewController alloc]init];
    //    details.hidesBottomBarWhenPushed = YES;    //用来隐藏标签栏
    //    details.projectId = model.projectId;
    //    details.categoryId = model.categoryId;
    //    details.isfromTodayDiscount=YES;
    //
    // [self.navigationController pushViewController:details animated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==0) {
        return 337;
    }else{
        return 8;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (ScreenWidth>375) {
        return 62;
    }else{
        return 49;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
